with open('input.txt') as file:
    count = 0

    for passport_lines in file.read().split('\n\n'):
        keys = set()

        for parts in passport_lines.split():
            key, _ = parts.split(':')
            keys.add(key)

        if len(keys) == 8 or (len(keys) == 7 and 'cid' not in keys):
            count += 1

    print(count)    
        